home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / vhdl-mode.info.z / vhdl-mode.info
Encoding:
GNU Info File  |  1998-05-21  |  41.1 KB  |  1,044 lines

  1. This is Info file ../info/vhdl-mode.info, produced by Makeinfo version
  2. 1.68 from the input file vhdl-mode.texi.
  3.  
  4.    Copyright (C) 1995 - 1997 Rodney J. Whitby <rwhitby@geocities.com>
  5.  
  6. 
  7. File: vhdl-mode.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  8.  
  9. * Menu:
  10.  
  11. * Introduction::
  12. * Getting Connected::
  13. * New Indentation Engine::
  14. * Customizing Indentation::
  15. * Syntactic Symbols::
  16. * Indentation Commands::
  17. * Frequently Asked Questions::
  18. * Getting the latest vhdl-mode release::
  19. * Sample .emacs File::
  20. * Requirements::
  21. * Limitations and Known Bugs::
  22. * Mailing Lists and Submitting Bug Reports::
  23. * Concept Index::
  24. * Command Index::               Command Index
  25. * Key Index::                   Key Index
  26. * Variable Index::              Variable Index
  27.  
  28. 
  29. File: vhdl-mode.info,  Node: Introduction,  Next: Getting Connected,  Prev: Top,  Up: Top
  30.  
  31. Introduction
  32. ************
  33.  
  34.    Welcome to `vhdl-mode', version 2.  This is a GNU Emacs mode for
  35. editing files containing VHDL code.
  36.  
  37.    This manual will describe the following:
  38.  
  39.    * How to get started using `vhdl-mode'.
  40.  
  41.    * How the new indentation engine works.
  42.  
  43.    * How to customize the new indentation engine.
  44.  
  45.    The major version number was incremented to 2 with the addition of
  46. the new indentation engine. To find the minor revision number of this
  47. release, use `M-x vhdl-version RET'.
  48.  
  49.    A special word of thanks goes to Barry Warsaw, who wrote the
  50. `cc-mode' indentation engine that formed the basis of the `vhdl-mode'
  51. indentation engine.  This manual is also based upon the manual for
  52. `cc-mode'.
  53.  
  54. 
  55. File: vhdl-mode.info,  Node: Getting Connected,  Next: New Indentation Engine,  Prev: Introduction,  Up: Top
  56.  
  57. Getting Connected
  58. *****************
  59.  
  60.    `vhdl-mode.el' works well with the 3 main branches of Emacs 19:
  61. XEmacs, Win-Emacs (which has the same heritage as XEmacs) and the Emacs
  62. 19 maintained by the FSF.  FSF's Emacs 19 users will want to use Emacs
  63. version 19.21 or better, Win-Emacs users will want 1.35 or better, and
  64. XEmacs users will want 19.6 or better.  Earlier versions of these
  65. Emacsen have deficiencies and/or bugs which will adversely affect the
  66. performance and usability of `vhdl-mode'.
  67.  
  68.    The first thing you will want to do is put `vhdl-mode.el' somewhere
  69. on your `load-path' so Emacs can find it.  Do a `C-h v load-path RET'
  70. to see all the directories Emacs looks at when loading a file.  If none
  71. of these directories are appropriate, create a new directory and add it
  72. to your `load-path':
  73.  
  74. *[in the shell]*
  75.  
  76.      % cd
  77.      % mkdir mylisp
  78.      % mv vhdl-mode.el mylisp
  79.      % cd mylisp
  80.  
  81. *[in your .emacs file add]*
  82.  
  83.      (setq load-path (cons "~/mylisp" load-path))
  84.  
  85.    Next you want to "byte compile" `vhdl-mode.el'.  The mode uses a lot
  86. of macros so if you don't byte compile it, things will be unbearably
  87. slow.  *You can ignore all byte-compiler warnings!*  They are the
  88. result of the supporting different versions of Emacs, and none of the
  89. warnings have any effect on operation. Let me say this again: *You
  90. really can ignore all byte-compiler warnings!*
  91.  
  92.    Here's what to do to byte-compile the file [in emacs]:
  93.  
  94.      M-x byte-compile-file RET ~/mylisp/vhdl-mode.el RET
  95.  
  96.    Now add the following autoloads to your `.emacs' file so that
  97. `vhdl-mode' gets loaded at the right time:
  98.  
  99.      (autoload 'vhdl-mode "vhdl-mode" "VHDL Editing Mode" t)
  100.  
  101.    Alternatively, if you want to make sure `vhdl-mode' is loaded when
  102. Emacs starts up, you could use this line instead of the autoload above:
  103.  
  104.      (require 'vhdl-mode)
  105.  
  106.    Next, you will want to set up Emacs so that it edits VHDL files in
  107. `vhdl-mode'. All users should add the following to their `.emacs' file.
  108. Note that this assumes you'll be editing `.vhd' and files as VHDL.
  109. YMMV:
  110.  
  111.      (setq auto-mode-alist
  112.        (append
  113.          '(("\\.vhd$" . vhdl-mode)
  114.           ) auto-mode-alist))
  115.  
  116.    That's all you need - I know, I know, it sounds like a lot `:-)',
  117. but after you've done all this, you should only need to quit and restart
  118. Emacs.  The next time you visit a VHDL file you should be using
  119. `vhdl-mode'.  You can check this easily by hitting `M-x vhdl-version
  120. RET' in the `vhdl-mode' buffer.  You should see this message in the
  121. echo area:
  122.  
  123.      Using `vhdl-mode' version 2.XXX
  124.  
  125. where XXX will be some minor revision number.
  126.  
  127. 
  128. File: vhdl-mode.info,  Node: New Indentation Engine,  Next: Indentation Commands,  Prev: Getting Connected,  Up: Top
  129.  
  130. New Indentation Engine
  131. **********************
  132.  
  133.    `vhdl-mode' has a new indentation engine, providing a simplified, yet
  134. flexible and general mechanism for customizing indentation. It breaks
  135. indentation calculation into two steps. First for the line of code being
  136. indented, `vhdl-mode' analyzes what kind of language construct it's
  137. looking at, then it applies user defined offsets to the current line
  138. based on this analysis.
  139.  
  140.    This section will briefly cover how indentation is calculated in
  141. `vhdl-mode'. It is important to understand the indentation model being
  142. used so that you will know how to customize `vhdl-mode' for your
  143. personal coding style.
  144.  
  145. * Menu:
  146.  
  147. * Syntactic Analysis::       Step 1 - Syntactic Analysis
  148. * Indentation Calculation::  Step 2 - Indentation Calculation
  149.  
  150. 
  151. File: vhdl-mode.info,  Node: Syntactic Analysis,  Next: Indentation Calculation,  Up: New Indentation Engine
  152.  
  153. Syntactic Analysis
  154. ==================
  155.  
  156.    The first thing `vhdl-mode' does when indenting a line of code, is
  157. to analyze the line, determining the "syntactic component list" of the
  158. construct on that line.  A "syntactic component" consists of a pair of
  159. information (in lisp parlance, a *cons cell*), where the first part is
  160. a "syntactic symbol", and the second part is a "relative buffer
  161. position".  Syntactic symbols describe elements of VHDL code, e.g.
  162. `statement', `comment', `block-open', `block-close', etc.  *Note
  163. Syntactic Symbols::, for a complete list of currently recognized
  164. syntactic symbols and their semantics.  Also, the variable
  165. `vhdl-offsets-alist' contains the list of currently supported syntactic
  166. symbols.
  167.  
  168.    Conceptually, a line of VHDL code is always indented relative to the
  169. indentation of some line higher up in the buffer.  This is represented
  170. by the relative buffer position in the syntactic component.
  171.  
  172.    It might help to see an example. Suppose we had the following code as
  173. the only thing in a `vhdl-mode' buffer (1):
  174.  
  175.        1: inverter : process
  176.        2: begin
  177.        3:   q <= not d;
  178.        4:   wait on d;
  179.        5: end inverter;
  180.  
  181.    We can use the command `C-c C-s' (`vhdl-show-syntactic-information')
  182. to simply report what the syntactic analysis is for the current line.
  183. Running this command on line 4 of example 1, we'd see in the echo area:
  184.  
  185.      ((statement . 28))
  186.  
  187.    This tells us that the line is a statement and it is indented
  188. relative to buffer position 28, which happens to be the `q' on line 3.
  189. If you were to move point to line 3 and hit `C-c C-s', you would see:
  190.  
  191.      ((statement-block-intro . 20))
  192.  
  193.    This indicates that line 3 is the first statement in a block, and is
  194. indented relative to buffer position 20, which is the `b' in the
  195. `begin' keyword on line 2.
  196.  
  197.    Syntactic component lists can contain more than one component, and
  198. individual syntactic compenents need not have relative buffer positions.
  199. The most common example of this is a line that contains a "comment only
  200. line".
  201.  
  202.      %%% TBD %%%
  203.  
  204. Hitting `C-c C-s' on line 3 of the example gives us:
  205.  
  206.      ((comment-intro) (block-intro . 46))
  207.  
  208. so you can see that the syntactic component list contains two syntactic
  209. components.  Also notice that the first component, `(comment-intro)'
  210. has no relative buffer position.
  211.  
  212.    ---------- Footnotes ----------
  213.  
  214.    (1) The line numbers in this and future examples don't actually
  215. appear in the buffer.
  216.  
  217. 
  218. File: vhdl-mode.info,  Node: Indentation Calculation,  Prev: Syntactic Analysis,  Up: New Indentation Engine
  219.  
  220. Indentation Calculation
  221. =======================
  222.  
  223.    Indentation for the current line is calculated using the syntactic
  224. component list derived in step 1 above (see *Note Syntactic
  225. Analysis::).  Each component contributes to the final total indentation
  226. of the line in two ways.
  227.  
  228.    First, the syntactic symbols are looked up in the
  229. `vhdl-offsets-alist' variable, which is an association list of
  230. syntactic symbols and the offsets to apply for those symbols.  These
  231. offsets are added to the running total.
  232.  
  233.    Second, if the component has a relative buffer position, `vhdl-mode'
  234. adds the column number of that position to the running total.  By adding
  235. up the offsets and columns for every syntactic component on the list,
  236. the final total indentation for the current line is computed.
  237.  
  238.    Let's use our code example above to see how this works.  Here is our
  239. example again.
  240.  
  241.        1: inverter : process
  242.        2: begin
  243.        3:   q <= not d;
  244.        4:   wait on d;
  245.        5: end inverter;
  246.  
  247.    Let's say point is on line 3 and we hit the <TAB> key to re-indent
  248. the line.  Remember that the syntactic component list for that line is:
  249.  
  250.      ((statement-block-intro . 20))
  251.  
  252. `vhdl-mode' looks up `statement-block-intro' in the
  253. `vhdl-offsets-alist' variable.  Let's say it finds the value `2'; it
  254. adds this to the running total (initialized to zero), yielding a
  255. running total indentation of 2 spaces.
  256.  
  257.    Next `vhdl-mode' goes to buffer position 20 and asks for the current
  258. column.  Since the `begin' keyword at buffer position 20 is in column
  259. zero, it adds `0' to the running total.  Since there is only one
  260. syntactic component on the list for this line, indentation calculation
  261. is complete, and the total indentation for the line is 2 spaces.
  262. Simple, huh?
  263.  
  264.    Actually, the mode usually just does The Right Thing without you
  265. having to think about it in this much detail.  But when customizing
  266. indentation, it's helpful to understand the general indentation model
  267. being used.
  268.  
  269.    To help you configure `vhdl-mode', you can set the variable
  270. `vhdl-echo-syntactic-information-p' to non-`nil' so that the syntactic
  271. component list and calculated offset will always be echoed in the
  272. minibuffer when you hit `TAB'.
  273.  
  274. 
  275. File: vhdl-mode.info,  Node: Indentation Commands,  Next: Customizing Indentation,  Prev: New Indentation Engine,  Up: Top
  276.  
  277. Indentation Commands
  278. ********************
  279.  
  280.    *<TBD>*
  281.  
  282. 
  283. File: vhdl-mode.info,  Node: Customizing Indentation,  Next: Syntactic Symbols,  Prev: Indentation Commands,  Up: Top
  284.  
  285. Customizing Indentation
  286. ***********************
  287.  
  288.    The `vhdl-offsets-alist' variable is where you customize all your
  289. indentations.  You simply need to decide what additional offset you want
  290. to add for every syntactic symbol.  You can use the command `C-c C-o'
  291. (`vhdl-set-offset') as the way to set offsets, both interactively and
  292. from your mode hook.  Also, you can set up *styles* of indentation.
  293. Most likely, you'll find one of the pre-defined styles will suit your
  294. needs, but if not, this section will describe how to set up basic
  295. editing configurations.  *Note Styles:: for an explanation of how to
  296. set up named styles.
  297.  
  298.    As mentioned previously, the variable `vhdl-offsets-alist' is an
  299. association list between syntactic symbols and the offsets to be applied
  300. for those symbols.  In fact, these offset values can be an integer, a
  301. function or variable name, or one of the following symbols: `+', `-',
  302. `++', `--', `*', or `/'.  The symbol values have the following meanings:
  303.  
  304.    * `+'  -  1 x `vhdl-basic-offset'
  305.  
  306.    * `-'  -  -1 x `vhdl-basic-offset'
  307.  
  308.    * `++' -  2 x `vhdl-basic-offset'
  309.  
  310.    * `--' -  -2 x `vhdl-basic-offset'
  311.  
  312.    * `*'  -  0.5 x `vhdl-basic-offset'
  313.  
  314.    * `/'  -  -0.5 x `vhdl-basic-offset'
  315.  
  316. So, for example, because most of the default offsets are defined in
  317. terms of `+', `-', and `0', if you like the general indentation style,
  318. but you use 2 spaces instead of 4 spaces per level, you can probably
  319. achieve your style just by changing `vhdl-basic-offset' like so (in
  320. your `.emacs' file):
  321.  
  322.      (setq vhdl-basic-offset 2)
  323.  
  324.    To change indentation styles more radically, you will want to change
  325. the value associated with the syntactic symbols in the
  326. `vhdl-offsets-alist' variable.  First, I'll show you how to do that
  327. interactively, then I'll describe how to make changes to your `.emacs'
  328. file so that your changes are more permanent.
  329.  
  330. * Menu:
  331.  
  332. * Interactive Customization::
  333. * Permanent Customization::
  334. * Styles::
  335. * Advanced Customizations::
  336.  
  337. 
  338. File: vhdl-mode.info,  Node: Interactive Customization,  Next: Permanent Customization,  Up: Customizing Indentation
  339.  
  340. Interactive Customization
  341. =========================
  342.  
  343.    As an example of how to customize indentation, let's change the
  344. style of the example above from:
  345.  
  346.        1: inverter : process
  347.        2: begin
  348.        3:   q <= not d;
  349.        4:   wait on d;
  350.        5: end inverter;
  351.  
  352. to:
  353.  
  354.        1: inverter : process
  355.        2: begin
  356.        3:     q <= not d;
  357.        4:     wait on d;
  358.        5: end inverter;
  359.  
  360.    In other words, we want to change the indentation of the statments
  361. inside the inverter process.  Notice that the construct we want to
  362. change starts on line 3.  To change the indentation of a line, we need
  363. to see which syntactic component affect the offset calculations for that
  364. line.  Hitting `C-c C-s' on line 3 yields:
  365.  
  366.      ((statement-block-intro . 20))
  367.  
  368. So we know that to change the offset of the first signal assignment, we
  369. need to change the indentation for the `statement-block-intro' syntactic
  370. symbol.  To do this interactively, just hit `C-c C-o'
  371. (`vhdl-set-offset').  This prompts you for the syntactic symbol to
  372. change, providing a reasonable default.  In this case, the default is
  373. `statement-block-intro', which is just the syntactic symbol we want to
  374. change!
  375.  
  376.    After you hit return, `vhdl-mode' will then prompt you for the new
  377. offset value, with the old value as the default.  The default in this
  378. case is `+', so hit backspace to delete the `+', then hit `++' and
  379. `RET'.  This will associate an offset of twice the basic indent with
  380. the syntactic symbol `statement-block-intro' in the
  381. `vhdl-offsets-alist' variable.
  382.  
  383.    To check your changes quickly, just hit `C-c C-q'
  384. (`vhdl-indent-defun') to reindent the entire function.  The example
  385. should now look like:
  386.  
  387.        1: inverter : process
  388.        2: begin
  389.        3:     q <= not d;
  390.        4:     wait on d;
  391.        5: end inverter;
  392.  
  393.    Notice how just changing the offset on line 3 is all we needed to do.
  394. Since the other affected lines are indented relative to line 3, they are
  395. automatically indented the way you'd expect.  For more complicated
  396. examples, this may not always work.  The general approach to take is to
  397. always start adjusting offsets for lines higher up in the file, then
  398. re-indent and see if any following lines need further adjustments.
  399.  
  400. 
  401. File: vhdl-mode.info,  Node: Permanent Customization,  Next: Styles,  Prev: Interactive Customization,  Up: Customizing Indentation
  402.  
  403. Permanent Indentation
  404. =====================
  405.  
  406.    To make this change permanent, you need to add some lisp code to your
  407. `.emacs' file.  `vhdl-mode' provides a `vhdl-mode-hook' that you can
  408. use to customize your language editing styles.  This hook gets run as
  409. the last thing when you enter `vhdl-mode'.
  410.  
  411.    Here's a simplified example of what you can add to your `.emacs'
  412. file to make the changes described in the previous section (*Note
  413. Interactive Customization::) more permanent.  See the Emacs manuals for
  414. more information on customizing Emacs via hooks.  *Note Sample .emacs
  415. File:: for a more complete sample `.emacs' file.  (1)
  416.  
  417.      (defun my-vhdl-mode-hook ()
  418.        ;; my customizations for all of vhdl-mode
  419.        (vhdl-set-offset 'statement-block-intro '++)
  420.        ;; other customizations can go here
  421.        )
  422.      (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
  423.  
  424.    For complex customizations, you will probably want to set up a
  425. *style* that groups all your customizations under a single name. *Note
  426. Styles:: for details.
  427.  
  428.    The offset value can also be a function, and this is how power users
  429. gain enormous flexibility in customizing indentation. *Note Advanced
  430. Customizations:: for details.
  431.  
  432.    ---------- Footnotes ----------
  433.  
  434.    (1) The use of `add-hook' in this example only works for Emacs 19.
  435. Workarounds are available if you are using Emacs 18, but this just
  436. points out another reason for you to upgrade to Emacs 19!  `:-)'
  437.  
  438. 
  439. File: vhdl-mode.info,  Node: Styles,  Next: Advanced Customizations,  Prev: Permanent Customization,  Up: Customizing Indentation
  440.  
  441. Styles
  442. ======
  443.  
  444.    Most people only need to edit code formatted in just a few
  445. well-defined and consistent styles.  For example, their organization
  446. might impose a "blessed" style that all its programmers must conform
  447. to.  Similarly, people who work on GNU software will have to use the
  448. GNU coding style on C code.  Some shops are more lenient, allowing some
  449. variety of coding styles, and as programmers come and go, there could
  450. be a number of styles in use.  For this reason, `vhdl-mode' makes it
  451. convenient for you to set up logical groupings of customizations called
  452. "styles", associate a single name for any particular style, and pretty
  453. easily start editing new or existing code using these styles.  This
  454. chapter describes how to set up styles and how to edit your C code
  455. using styles.
  456.  
  457. * Menu:
  458.  
  459. * Built-in Styles::
  460. * Adding Styles::
  461. * File Styles::
  462.  
  463. 
  464. File: vhdl-mode.info,  Node: Built-in Styles,  Next: Adding Styles,  Up: Styles
  465.  
  466. Built-in Styles
  467. ---------------
  468.  
  469.    If you're lucky, one of `vhdl-mode''s built-in styles might be just
  470. what you're looking for.  Some of the most common VHDL styles are
  471. already built-in.  These include:
  472.  
  473.    * `GNU' - the coding style in the IEEE Language Reference Manual.
  474.  
  475.    If you'd like to experiment with these built-in styles you can simply
  476. type the following in a `vhdl-mode' buffer:
  477.  
  478.      M-x vhdl-set-style RET.
  479.  
  480. You will be prompted for one of the above styles (with completion).
  481. Enter one of the styles and hit `RET'.  Note however that setting a
  482. style in this way does *not* automatically re-indent your file.  For
  483. commands that you can use to view the effect of your changes, see *Note
  484. Indentation Commands::.
  485.  
  486.    Once you find a built-in style you like, you can make the change
  487. permanent by adding a call to your `.emacs' file.  Let's say for
  488. example that you want to use the `IEEE' style in all your files.  You
  489. would add this:
  490.  
  491.      (defun my-vhdl-mode-hook ()
  492.        ;; use IEEE style for all VHDL code
  493.        (vhdl-set-style "IEEE")
  494.        ;; other customizations can go here
  495.        )
  496.      (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
  497.  
  498. *Note Permanent Customization::.
  499.  
  500. 
  501. File: vhdl-mode.info,  Node: Adding Styles,  Next: File Styles,  Prev: Built-in Styles,  Up: Styles
  502.  
  503. Adding Styles
  504. -------------
  505.  
  506.    If none of the built-in styles is appropriate, you'll probably want
  507. to add a new style definition.  Styles are kept in the
  508. `vhdl-style-alist' variable, but you probably won't want to modify this
  509. variable directly.  `vhdl-mode' provides a function, called
  510. `vhdl-add-style', that you can use to easily add new styles or update
  511. existing styles.  This function takes two arguments, a STYLENAME
  512. string, and an association list DESCRIPTION of style customizations.  If
  513. STYLENAME is not already in `vhdl-style-alist', the new style is added,
  514. otherwise the style already associated with STYLENAME is changed to the
  515. new DESCRIPTION.  This function also takes an optional third argument,
  516. which if non-`nil', automatically institutes the new style in the
  517. current buffer.
  518.  
  519.    The sample `.emacs' file provides a concrete example of how a new
  520. style can be added and automatically set.  *Note Sample .emacs File::.
  521.  
  522. 
  523. File: vhdl-mode.info,  Node: File Styles,  Prev: Adding Styles,  Up: Styles
  524.  
  525. File Styles
  526. -----------
  527.  
  528.    The Emacs manual describes how you can customize certain variables
  529. on a per-file basis by including a "Local Variable" block at the end of
  530. the file.  So far, you've only seen a functional interface to
  531. `vhdl-mode', which is highly inconvenient for use in a Local Variable
  532. block.  `vhdl-mode' provides two variables that make it easier for you
  533. to customize your style on a per-file basis.
  534.  
  535.    The variable `vhdl-file-style' can be set to a style name string as
  536. described in *Note Built-in Styles::.  When the file is visited,
  537. `vhdl-mode' will automatically set the file's style to this style using
  538. `vhdl-set-style'.
  539.  
  540.    Another variable, `vhdl-file-offsets', takes an association list
  541. similar to what is allowed in `vhdl-offsets-alist'.  When the file is
  542. visited, `vhdl-mode' will automatically institute these offets using
  543. `vhdl-set-offset'.  *Note Customizing Indentation::.
  544.  
  545.    Note that file style settings (i.e. `vhdl-file-style') are applied
  546. before file offset settings (i.e. `vhdl-file-offsets').
  547.  
  548. 
  549. File: vhdl-mode.info,  Node: Advanced Customizations,  Prev: Styles,  Up: Customizing Indentation
  550.  
  551. Advanced Customizations
  552. =======================
  553.  
  554.    For most users, `vhdl-mode' will support their coding styles with
  555. very little need for customizations.  Usually, one of the standard
  556. styles defined in `vhdl-style-alist' will do the trick.  Sometimes, one
  557. of the syntactic symbol offsets will need to be tweeked slightly, or
  558. perhaps `vhdl-basic-offset' will need to be changed.  However, some
  559. styles require a more advanced ability for customization, and one of the
  560. real strengths of `vhdl-mode' is that the syntactic analysis model
  561. provides a very flexible framework for customizing indentation. This
  562. allows you to perform special indentation calculations for situations
  563. not handled by the mode directly.
  564.  
  565. * Menu:
  566.  
  567. * Custom Indentation Functions::
  568. * Other Special Indentations::
  569.  
  570. 
  571. File: vhdl-mode.info,  Node: Custom Indentation Functions,  Next: Other Special Indentations,  Up: Advanced Customizations
  572.  
  573. Custom Indentation Functions
  574. ----------------------------
  575.  
  576.    One of the most common ways to customize `vhdl-mode' is by writing
  577. "custom indentation functions" and associating them with specific
  578. syntactic symbols (see *Note Syntactic Symbols::).  `vhdl-mode' itself
  579. uses custom indentation functions to provide more sophisticated
  580. indentation, for example when lining up selected signal assignments:
  581.  
  582.      %%% TBD %%%
  583.  
  584.    In this example, the `statement-cont' syntactic symbol has an offset
  585. of `+', and `vhdl-basic-offset' is 2, so lines 4 through 6 are simply
  586. indented two spaces to the right of line 3.  But perhaps we'd like
  587. `vhdl-mode' to be a little more intelligent so that it offsets the
  588. waveform descriptions relative to the signal assignment operator in
  589. line 3.  To do this, we have to write a custom indentation function
  590. which finds the column of signal assignment operator on the first line
  591. of the statement.  Here is the lisp code (from the `vhdl-mode.el'
  592. source file) that implements this:
  593.  
  594.      (defun vhdl-lineup-statement-cont (langelem)
  595.        ;; line up statement-cont after the assignment operator
  596.        (save-excursion
  597.          (let* ((relpos (cdr langelem))
  598.             (assignp (save-excursion
  599.                   (goto-char (vhdl-point 'boi))
  600.                   (and (re-search-forward "\\(<\\|:\\)="
  601.                               (vhdl-point 'eol) t)
  602.                    (- (point) (vhdl-point 'boi)))))
  603.             (curcol (progn
  604.                   (goto-char relpos)
  605.                   (current-column)))
  606.             foundp)
  607.            (while (and (not foundp)
  608.                (< (point) (vhdl-point 'eol)))
  609.          (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
  610.          (if (vhdl-in-literal (cdr langelem))
  611.              (forward-char)
  612.            (if (= (preceding-char) ?\()
  613.                ;; skip over any parenthesized expressions
  614.                (goto-char (min (vhdl-point 'eol)
  615.                        (scan-lists (point) 1 1)))
  616.              ;; found an assignment operator (not at eol)
  617.              (setq foundp (not (looking-at "\\s-*$"))))))
  618.            (if (not foundp)
  619.            ;; there's no assignment operator on the line
  620.            vhdl-basic-offset
  621.          ;; calculate indentation column after assign and ws, unless
  622.          ;; our line contains an assignment operator
  623.          (if (not assignp)
  624.              (progn
  625.                (forward-char)
  626.                (skip-chars-forward " \t")
  627.                (setq assignp 0)))
  628.          (- (current-column) assignp curcol))
  629.            )))
  630.  
  631. Custom indent functions take a single argument, which is a syntactic
  632. component cons cell (see *Note Syntactic Analysis::).  The function
  633. returns an integer offset value that will be added to the running total
  634. indentation for the lne.  Note that what actually gets returned is the
  635. difference between the column that the signal assignment operator is
  636. on, and the column of the buffer relative position passed in the
  637. function's argument.  Remember that `vhdl-mode' automatically adds in
  638. the column of the component's relative buffer position and we don't
  639. want that value added into the final total twice.
  640.  
  641.    Now, to associate the function `vhdl-lineup-statement-cont' with the
  642. `statement-cont' syntactic symbol, we can add something like the
  643. following to our `vhdl-mode-hook':
  644.  
  645.      (vhdl-set-offset 'statement-cont 'vhdl-lineup-statement-cont)
  646.  
  647.    Now the function looks like this after re-indenting (using `C-c
  648. C-q'):
  649.  
  650.      %%% TBD %%%
  651.  
  652.    Custom indentation functions can be as simple or as complex as you
  653. like, and any syntactic symbol that appears in `vhdl-offsets-alist' can
  654. have a custom indentation function associated with it.  Note however
  655. that using many custom indentation functions may have a performance
  656. impact on `vhdl-mode'.
  657.  
  658. 
  659. File: vhdl-mode.info,  Node: Other Special Indentations,  Prev: Custom Indentation Functions,  Up: Advanced Customizations
  660.  
  661. Other Special Indentations
  662. --------------------------
  663.  
  664.    One other variable is available for you to customize `vhdl-mode':
  665. `vhdl-special-indent-hook'.  This is a standard hook variable that is
  666. called after every line is indented by `vhdl-mode'.  You can use it to
  667. do any special indentation or line adjustments your style dictates,
  668. such as adding extra indentation to the port map clause in a component
  669. instantiation, etc.  Note however, that you should not change `point'
  670. or `mark' inside your `vhdl-special-indent-hook' functions.
  671.  
  672. 
  673. File: vhdl-mode.info,  Node: Syntactic Symbols,  Next: Frequently Asked Questions,  Prev: Customizing Indentation,  Up: Top
  674.  
  675. Syntactic Symbols
  676. *****************
  677.  
  678.    The complete list of recognized syntactic symbols is described in the
  679. `vhdl-offsets-alist' variable.  This chapter will provide some examples
  680. to help clarify these symbols.
  681.  
  682.    Most syntactic symbol names follow a general naming convention.
  683. When a line begins with a `begin' or `end' keyword, the syntactic
  684. symbol will contain the suffix `-open' or `-close' respectively.
  685.  
  686.    Usually, a distinction is made between the first line that
  687. introduces a construct and lines that continue a construct, and the
  688. syntactic symbols that represent these lines will contain the suffix
  689. `-intro' or `-cont' respectively.  As a sub-classification of this
  690. scheme, a line which is the first of a particular block construct will
  691. contain the suffix `-block-intro'.
  692.  
  693.    *<TBD> include the name and a brief example of every syntactic
  694. symbol currently recognized*
  695.  
  696. 
  697. File: vhdl-mode.info,  Node: Frequently Asked Questions,  Next: Getting the latest vhdl-mode release,  Prev: Syntactic Symbols,  Up: Top
  698.  
  699. Frequently Asked Questions
  700. **************************
  701.  
  702.      *Q.* *How do I re-indent the whole file?*
  703.  
  704.      *A.* Visit the file and hit `C-x h' to mark the whole buffer. Then
  705.      hit `<ESC> C-\' to re-indent the entire region which you've just
  706.      marked.
  707.  
  708.      *Q.* *How do I re-indent the entire function?*
  709.  
  710.      *A.* Hit `<ESC> C-h' to mark the entire function. Then hit `<ESC>
  711.      C-\' to re-indent the entire region which you've just marked.
  712.  
  713.      *Q.* *How do I re-indent the current block?*
  714.  
  715.      *A.* First move to the brace which opens the block with `<ESC>
  716.      C-u', then re-indent that expression with `<ESC> C-q'.
  717.  
  718.      *Q.* *How do I re-indent the current statement?*
  719.  
  720.      *A.* First move to the beginning of the statement with `<ESC> a',
  721.      then re-indent that expression with `<ESC> C-q'.
  722.  
  723.      *Q.* *Why doesn't the <RET> key indent the line to where the new
  724.      text should go after inserting the newline?*
  725.  
  726.      *A.* Emacs' convention is that <RET> just adds a newline, and that
  727.      <LFD> adds a newline and indents it.  You can make <RET> do this
  728.      too by adding this to your `vhdl-mode-hook' (see the sample
  729.      `.emacs' file *Note Sample .emacs File::):
  730.  
  731.           (define-key vhdl-mode-map "\C-m" 'newline-and-indent)
  732.  
  733.      This is a very common question. `:-)' If you want this to be the
  734.      default behavior, don't lobby me, lobby RMS!
  735.  
  736.      *Q.* *I put `(vhdl-set-offset 'statement-cont 0)' in my `.emacs'
  737.      file but I get an error saying that `vhdl-set-offset''s function
  738.      definition is void.*
  739.  
  740.      *A.* This means that `vhdl-mode' wasn't loaded into your Emacs
  741.      session by the time the `vhdl-set-offset' call was reached, mostly
  742.      likely because `vhdl-mode' is being autoloaded.  Instead of
  743.      putting the `vhdl-set-offset' line in your top-level `.emacs'
  744.      file, put it in your `vhdl-mode-hook', or simply add the following
  745.      to the top of your `.emacs' file:
  746.  
  747.           (require 'vhdl-mode)
  748.  
  749.      See the sample `.emacs' file *Note Sample .emacs File:: for
  750.      details.
  751.  
  752.  
  753. 
  754. File: vhdl-mode.info,  Node: Getting the latest vhdl-mode release,  Next: Sample .emacs File,  Prev: Frequently Asked Questions,  Up: Top
  755.  
  756. Getting the latest `vhdl-mode' release
  757. **************************************
  758.  
  759.    The best way to be sure you always have the latest `vhdl-mode'
  760. release is to join the `vhdl-mode-announce' mailing list.  If you are a
  761. brave soul, and wish to participate in beta testing of new releases of
  762. `vhdl-mode', you may also join the `vhdl-mode-victims' mailing list.
  763. Send email to the author to join either of these lists.
  764.  
  765.    The Official `VHDL-Mode' Home Page can be found at
  766. `http://www.geocities.com/SiliconValley/Park/8287/vhdl-mode.html'.
  767.  
  768. 
  769. File: vhdl-mode.info,  Node: Sample .emacs File,  Next: Requirements,  Prev: Getting the latest vhdl-mode release,  Up: Top
  770.  
  771. Sample `.emacs' file
  772. ********************
  773.  
  774.      ;; Here's a sample .emacs file that might help you along the way.  Just
  775.      ;; copy this region and paste it into your .emacs file.  You may want to
  776.      ;; change some of the actual values.
  777.      
  778.      (defconst my-vhdl-style
  779.        '((vhdl-tab-always-indent        . t)
  780.          (vhdl-comment-only-line-offset . 4)
  781.          (vhdl-offsets-alist            . ((arglist-close    . vhdl-lineup-arglist)
  782.                                            (statement-cont   . 0)
  783.                                            (case-alternative . 4)
  784.                                            (block-open       . 0)))
  785.          (vhdl-echo-syntactic-information-p . t)
  786.          )
  787.        "My VHDL Programming Style")
  788.      
  789.      ;; Customizations for vhdl-mode
  790.      (defun my-vhdl-mode-hook ()
  791.        ;; add my personal style and set it for the current buffer
  792.        (vhdl-add-style "PERSONAL" my-vhdl-style t)
  793.        ;; offset customizations not in my-vhdl-style
  794.        (vhdl-set-offset 'statement-case-intro '++)
  795.        ;; other customizations
  796.        (setq tab-width 8
  797.              ;; this will make sure spaces are used instead of tabs
  798.              indent-tabs-mode nil)
  799.        ;; keybindings for VHDL are put in vhdl-mode-map
  800.        (define-key vhdl-mode-map "\C-m" 'newline-and-indent)
  801.        )
  802.      
  803.      ;; the following only works in Emacs 19
  804.      ;; Emacs 18ers can use (setq vhdl-mode-hook 'my-vhdl-mode-hook)
  805.      (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
  806.  
  807. 
  808. File: vhdl-mode.info,  Node: Requirements,  Next: Limitations and Known Bugs,  Prev: Sample .emacs File,  Up: Top
  809.  
  810. Requirements
  811. ************
  812.  
  813.    `vhdl-mode.el' requires `reporter.el' for submission of bug reports.
  814. `reporter.el' is distributed with the latest FSF and XEmacs 19's.
  815. Here is the Emacs Lisp Archive anonymous ftp'ing record for those of
  816. you who are using older Emacsen.
  817.  
  818.  
  819.               GNU Emacs Lisp Code Directory Apropos -- "reporter"
  820.      "~/" refers to archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/
  821.      
  822.      reporter (2.12)       06-Jul-1994
  823.           Barry A. Warsaw, <bwarsaw@cen.com>
  824.           ~/misc/reporter.el.Z
  825.           Customizable bug reporting of lisp programs.
  826.  
  827. 
  828. File: vhdl-mode.info,  Node: Limitations and Known Bugs,  Next: Mailing Lists and Submitting Bug Reports,  Prev: Requirements,  Up: Top
  829.  
  830. Limitations and Known Bugs
  831. **************************
  832.  
  833.    * Re-indenting large regions or expressions can be slow.
  834.  
  835.    * Use with Emacs 18 can be slow and annoying. You should seriously
  836.      consider upgrading to Emacs 19.
  837.  
  838. 
  839. File: vhdl-mode.info,  Node: Mailing Lists and Submitting Bug Reports,  Next: Concept Index,  Prev: Limitations and Known Bugs,  Up: Top
  840.  
  841. Mailing Lists and Submitting Bug Reports
  842. ****************************************
  843.  
  844.    To report bugs, use the `C-c C-b' (`vhdl-submit-bug-report')
  845. command.  This provides vital information I need to reproduce your
  846. problem.  Make sure you include a concise, but complete code example.
  847. Please try to boil your example down to just the essential code needed
  848. to reproduce the problem, and include an exact recipe of steps needed to
  849. expose the bug.  Be especially sure to include any code that appears
  850. *before* your bug example.
  851.  
  852.    For other help or suggestions, send a message to
  853. `rwhitby@geocities.com'.
  854.  
  855.    Send an add message to `rwhitby@geocities.com' to get on the
  856. `vhdl-mode-victims' beta testers list where beta releases of
  857. `vhdl-mode' are posted.  Note that you shouldn't expect beta releases
  858. to be as stable as public releases.
  859.  
  860.    There is also an announce only list where the latest public releases
  861. of `vhdl-mode' are posted.  Send an add message to
  862. `rwhitby@geocities.com' to be added to this list.
  863.  
  864. 
  865. File: vhdl-mode.info,  Node: Concept Index,  Next: Command Index,  Prev: Mailing Lists and Submitting Bug Reports,  Up: Top
  866.  
  867. Concept Index
  868. *************
  869.  
  870. * Menu:
  871.  
  872. * -block-intro syntactic symbols:        Syntactic Symbols.
  873. * -close syntactic symbols:              Syntactic Symbols.
  874. * -cont syntactic symbols:               Syntactic Symbols.
  875. * -intro syntactic symbols:              Syntactic Symbols.
  876. * -open syntactic symbols:               Syntactic Symbols.
  877. * .emacs file:                           Getting Connected.
  878. * Adding Styles:                         Adding Styles.
  879. * Advanced Customizations:               Advanced Customizations.
  880. * announcement mailing list:             Mailing Lists and Submitting Bug Reports.
  881. * basic-offset (vhdl-):                  Customizing Indentation.
  882. * beta testers mailing list:             Mailing Lists and Submitting Bug Reports.
  883. * Built-in Styles:                       Built-in Styles.
  884. * byte compile:                          Getting Connected.
  885. * comment only line:                     Syntactic Analysis.
  886. * custom indentation functions:          Custom Indentation Functions.
  887. * Custom Indentation Functions:          Custom Indentation Functions.
  888. * Customizing Indentation:               Customizing Indentation.
  889. * File Styles:                           File Styles.
  890. * Frequently Asked Questions:            Frequently Asked Questions.
  891. * Getting Connected:                     Getting Connected.
  892. * Getting the latest vhdl-mode release:  Getting the latest vhdl-mode release.
  893. * hooks:                                 Permanent Customization.
  894. * IEEE style:                            Built-in Styles.
  895. * Indentation Calculation:               Indentation Calculation.
  896. * Indentation Commands:                  Indentation Commands.
  897. * Interactive Customization:             Interactive Customization.
  898. * Introduction:                          Introduction.
  899. * Limitations and Known Bugs:            Limitations and Known Bugs.
  900. * local variables:                       File Styles.
  901. * Mailing Lists and Submitting Bug Reports: Mailing Lists and Submitting Bug Reports.
  902. * New Indentation Engine:                New Indentation Engine.
  903. * Other Special Indentations:            Other Special Indentations.
  904. * Permanent Indentation:                 Permanent Customization.
  905. * relative buffer position:              Syntactic Analysis.
  906. * reporter.el:                           Requirements.
  907. * Requirements:                          Requirements.
  908. * Sample .emacs file:                    Sample .emacs File.
  909. * set-offset (vhdl-):                    Customizing Indentation.
  910. * statement-cont syntactic symbol:       Custom Indentation Functions.
  911. * Styles:                                Styles.
  912. * Syntactic Analysis:                    Syntactic Analysis.
  913. * syntactic component:                   Syntactic Analysis.
  914. * syntactic component list:              Syntactic Analysis.
  915. * syntactic symbol:                      Syntactic Analysis.
  916. * Syntactic Symbols:                     Syntactic Symbols.
  917. * TAB:                                   Indentation Calculation.
  918. * vhdl-basic-offset:                     Customizing Indentation.
  919. * vhdl-set-offset:                       Customizing Indentation.
  920.  
  921. 
  922. File: vhdl-mode.info,  Node: Command Index,  Next: Key Index,  Prev: Concept Index,  Up: Top
  923.  
  924. Command Index
  925. *************
  926.  
  927.    Since all `vhdl-mode' commands are prepended with the string
  928. `vhdl-', each appears under its `vhdl-<thing>' name and its `<thing>
  929. (vhdl-)' name.
  930.  
  931. * Menu:
  932.  
  933. * add-style (vhdl-):                     Adding Styles.
  934. * indent-defun (vhdl-):                  Interactive Customization.
  935. * lineup-statement-cont (vhdl-):         Custom Indentation Functions.
  936. * newline-and-indent:                    Frequently Asked Questions.
  937. * set-offset (vhdl-) <1>:                File Styles.
  938. * set-offset (vhdl-):                    Interactive Customization.
  939. * set-style (vhdl-):                     Built-in Styles.
  940. * show-syntactic-information (vhdl-):    Syntactic Analysis.
  941. * submit-bug-report (vhdl-):             Mailing Lists and Submitting Bug Reports.
  942. * vhdl-add-style:                        Adding Styles.
  943. * vhdl-indent-defun:                     Interactive Customization.
  944. * vhdl-lineup-statement-cont:            Custom Indentation Functions.
  945. * vhdl-set-offset <1>:                   File Styles.
  946. * vhdl-set-offset:                       Interactive Customization.
  947. * vhdl-set-style:                        Built-in Styles.
  948. * vhdl-show-syntactic-information:       Syntactic Analysis.
  949. * vhdl-submit-bug-report:                Mailing Lists and Submitting Bug Reports.
  950. * vhdl-version:                          Introduction.
  951.  
  952. 
  953. File: vhdl-mode.info,  Node: Key Index,  Next: Variable Index,  Prev: Command Index,  Up: Top
  954.  
  955. Key Index
  956. *********
  957.  
  958. * Menu:
  959.  
  960. * C-c C-b:                               Mailing Lists and Submitting Bug Reports.
  961. * C-c C-o:                               Interactive Customization.
  962. * C-c C-q <1>:                           Frequently Asked Questions.
  963. * C-c C-q <2>:                           Custom Indentation Functions.
  964. * C-c C-q:                               Interactive Customization.
  965. * C-c C-s:                               Syntactic Analysis.
  966. * C-x h:                                 Frequently Asked Questions.
  967. * ESC C-\:                               Frequently Asked Questions.
  968. * ESC C-q:                               Frequently Asked Questions.
  969. * ESC C-u:                               Frequently Asked Questions.
  970. * LFD:                                   Frequently Asked Questions.
  971. * RET:                                   Frequently Asked Questions.
  972. * TAB:                                   Indentation Calculation.
  973.  
  974. 
  975. File: vhdl-mode.info,  Node: Variable Index,  Prev: Key Index,  Up: Top
  976.  
  977. Variable Index
  978. **************
  979.  
  980.    Since all `vhdl-mode' variables are prepended with the string
  981. `vhdl-', each appears under its `vhdl-<thing>' name and its `<thing>
  982. (vhdl-)' name.
  983.  
  984. * Menu:
  985.  
  986. * basic-offset (vhdl-):                  Advanced Customizations.
  987. * echo-syntactic-information-p (vhdl-):  Indentation Calculation.
  988. * file-offsets (vhdl-):                  File Styles.
  989. * file-style (vhdl-):                    File Styles.
  990. * offsets-alist (vhdl-) <1>:             Custom Indentation Functions.
  991. * offsets-alist (vhdl-) <2>:             File Styles.
  992. * offsets-alist (vhdl-) <3>:             Indentation Calculation.
  993. * offsets-alist (vhdl-):                 Syntactic Analysis.
  994. * special-indent-hook (vhdl-):           Other Special Indentations.
  995. * style-alist (vhdl-) <1>:               Advanced Customizations.
  996. * style-alist (vhdl-):                   Adding Styles.
  997. * vhdl-basic-offset:                     Advanced Customizations.
  998. * vhdl-echo-syntactic-information-p:     Indentation Calculation.
  999. * vhdl-file-offsets:                     File Styles.
  1000. * vhdl-file-style:                       File Styles.
  1001. * vhdl-mode-hook:                        Permanent Customization.
  1002. * vhdl-offsets-alist <1>:                Syntactic Symbols.
  1003. * vhdl-offsets-alist <2>:                Custom Indentation Functions.
  1004. * vhdl-offsets-alist <3>:                File Styles.
  1005. * vhdl-offsets-alist <4>:                Indentation Calculation.
  1006. * vhdl-offsets-alist:                    Syntactic Analysis.
  1007. * vhdl-special-indent-hook:              Other Special Indentations.
  1008. * vhdl-style-alist <1>:                  Advanced Customizations.
  1009. * vhdl-style-alist:                      Adding Styles.
  1010.  
  1011.  
  1012. 
  1013. Tag Table:
  1014. Node: Top184
  1015. Node: Introduction759
  1016. Node: Getting Connected1559
  1017. Node: New Indentation Engine4265
  1018. Node: Syntactic Analysis5167
  1019. Node: Indentation Calculation7730
  1020. Node: Indentation Commands10042
  1021. Node: Customizing Indentation10223
  1022. Node: Interactive Customization12311
  1023. Node: Permanent Customization14653
  1024. Node: Styles16229
  1025. Node: Built-in Styles17214
  1026. Node: Adding Styles18487
  1027. Node: File Styles19524
  1028. Node: Advanced Customizations20634
  1029. Node: Custom Indentation Functions21517
  1030. Node: Other Special Indentations25294
  1031. Node: Syntactic Symbols25955
  1032. Node: Frequently Asked Questions26964
  1033. Node: Getting the latest vhdl-mode release29143
  1034. Node: Sample .emacs File29820
  1035. Node: Requirements31446
  1036. Node: Limitations and Known Bugs32152
  1037. Node: Mailing Lists and Submitting Bug Reports32515
  1038. Node: Concept Index33664
  1039. Node: Command Index36898
  1040. Node: Key Index38344
  1041. Node: Variable Index39372
  1042. 
  1043. End Tag Table
  1044.